local M = {}

function M.init()
  M.config()
  if vim.g.transparent_background or vim.g.neovide then
    M.background()
  end
  M.refresh(60, 5)
end

function M.config()
  vim.o.guifont = "Hack Nerd Font Mono:h15"
  vim.g.neovide_no_idle = true
  vim.g.neovide_confirm_quit = true
  -- always_quit always_detach prompt
  vim.g.neovide_detach_on_quit = "always_quit"
  vim.g.neovide_fullscreen = true
  vim.g.neovide_remember_window_size = true
  vim.g.neovide_cursor_vfx_mode = "railgun"
  -- 文本区域
  vim.g.neovide_padding_top = 0
  vim.g.neovide_padding_bottom = 0
  vim.g.neovide_padding_right = 0
  vim.g.neovide_padding_left = 0

  -- 文本对比度
  vim.g.neovide_text_gamma = 0.0
  vim.g.neovide_text_contrast = 0.5
end

function M.background()
  -- 窗体模糊
  vim.g.neovide_window_blurred = false
  vim.g.neovide_floating_blur_amount_x = 2.0
  vim.g.neovide_floating_blur_amount_y = 2.0
  -- 透明度
  vim.g.neovide_transparency = 0.7
  vim.g.gransparency = 1
  -- vim.g.neovide_background_color = "#00f00f"
  -- 浮动窗口阴影
  vim.g.neovide_floating_shadow = true
  vim.g.neovide_floating_z_height = 10
  vim.g.neovide_light_angle_degrees = 45
  vim.g.neovide_light_radius = 5
  -- 显示边框
  vim.g.neovide_show_border = true
  -- 动画速度
  -- vim.g.neovide_position_animation_length = 0.7
  -- vim.g.neovide_scroll_animation_far_lines = 1
  -- vim.g.neovide_cursor_animation_length = 0.13
  -- vim.g.neovide_cursor_trail_size = 0.8
  vim.g.neovide_cursor_animate_command_line = true
  -- 下划线自动缩放
  vim.g.neovide_underline_stroke_scale = 1.0
  -- light dark auto
  vim.g.neovide_theme = "dark"
end

function M.refresh(run_fps, free_fps)
  vim.g.neovide_refresh_rate = run_fps
  vim.g.neovide_refresh_rate_idle = free_fps
end

return M
